package com.jsmile.cloud.msgcenter.zf.strategy.notify;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jsmile.cloud.msgcenter.zf.enums.AliNotifyTypeEnum;
import com.jsmile.cloud.msgcenter.zf.strategy.interfaces.IAlilNotify;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class SpChangeNotifyStrategy implements IAlilNotify {

    @Override
    public String getNotifyType() {
        return AliNotifyTypeEnum.SP_CHANGED.getType();
    }

    /**
     * 授权模板，使用平台第三方的appId
     *
     * @param data
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String excute(String data) {
        log.info("代运营授权回调参数：{}", data);
        // 解析回调消息请求参数
        String requset = data.replace("\\", "").replace("\"{", "{").replace("}\"", "}");
        log.info("转字符串授权回调参数：{}", requset);
        JSONObject jsonObject = JSON.parseObject(requset).getJSONObject("biz_content");
        return SUCCESS;
    }

}
